package easy;

public class Solution_1221 {

    public int balancedStringSplit(String s) {
        int count = 0;
        char[] chars = s.toCharArray();
        for (int i = 0, count_l = 0; i < chars.length; i++) {
            if (chars[i] == 'L') {
                count_l++;
            } else {
                count_l--;
            }
            if (count_l==0) {
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Solution_1221 model = new Solution_1221();
        System.out.println(model.balancedStringSplit("RLRRLLRLRL"));
        System.out.println(model.balancedStringSplit("RLLLLRRRLR"));
        System.out.println(model.balancedStringSplit("LLLLRRRR"));
        System.out.println(model.balancedStringSplit("RLRRRLLRLL"));
    }
}
